 package com.github.niefy.modules.wx.entity;

 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.github.niefy.common.utils.Json;
 import lombok.Data;
 import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;

 import java.io.Serializable;
 import java.util.Date;

/**
 * 订阅通知消息模板
 * @author liuxy
 * @date 2022-12-16
 */
@Data
@TableName("wx_sub_msg_template")
public class SubMsgTemplate implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(type = IdType.AUTO)
    private Long id;
    private String appid;
    private String templateId;
    private int type;
    @TableField(value = "\"name\"")
    private String name;
    private String title;
    private String content;
    private String contentColor;
    private JSONArray data;
    private String example;
    private String page;
    private JSONObject miniprogram;
    @TableField(value = "\"status\"")
    private boolean status;
    private Date updateTime;
    public SubMsgTemplate() {

    }
    public SubMsgTemplate(TemplateInfo templateInfo, String appid) {
        this.appid = appid;
        this.templateId=templateInfo.getPriTmplId();
        this.title=templateInfo.getTitle();
        this.name=templateInfo.getPriTmplId();
        this.content = templateInfo.getContent();
        this.example = templateInfo.getExample();
        this.status=true;
    }

    @Override
    public String toString() {
        return Json.toJsonString(this);
    }

}
